
<style type="text/css">
  	span.error{
    	background:no-repeat;
    	float:left;
    	margin-left:3em;
        clear: both;
        color: red;
  	}
</style>
<script>
   $(function(){
       var roleTable = $(".role-table");
       for(var k = 0; k < roleTable.length; k++){
           var typelist = $(roleTable[k]).find("td[data-roletype]");
           var firstTr = $(typelist[0]).parent();
           for(var i = 0; i < typelist.length; i++){
               var typeTd = typelist[i];
               if($(typeTd).data("roletype") == "0"){
                   $(typeTd).html("应用角色");
                   var typeTr = $(typeTd).parent();
                   $(typeTr).insertBefore($(firstTr));
                   firstTr = typeTr;
               }else{
                   $(typeTd).html("用户组角色");
               }
           }
       }

   })
</script>

<!-- 增加用户窗口 -->
<div id="addUserModal" class="modal fade " data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-height="350" style="display: none;">
	  <!-- <div class="modal-dialog"> -->
      	<!-- <div class="modal-content"> -->
		<form  id = "addUserForm" style="margin: 0"  name="dataForm" method="post"
			action="addUserAndRoles">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal"
				aria-hidden="true">×</button>
				<h3 id="myModalLabel">新增用户</h3>
		</div>
		<div class="modal-body" style=" overflow: scroll; height: 350px; ">
			<table border="0" cellpaddilistng="0" cellspacing="0" class="table table-bordered">
				<tbody id="tbody-adduser-rolelist">
					<tr>
						<td style=" width: 25%; "> <span> *用户名 ： </span></td>
						<td><input type="text" id="input-adduser-username" name = "username" class="form-control wid200px"></td>
					</tr>
					<tr>
						<td><span> *密码 ：</span></td>
						<td>
							<input type="password" style="display:none" />
							<input type="password" id="input-adduser-password" name = "password" class="form-control wid200px" onpaste="return false" >
							
							<!-- 隐藏提交 -->
							<!-- <input type="hidden" id="input-adduser-address" name = "address" class="form-control wid200px"> -->
						</td>
					</tr>
					<tr>
						<td><span> 密码确认 ：</span></td>
						<td>
							<input type="password" id="adduser-crmPassword" name="crmPassword" class="form-control wid200px" onpaste="return false" >
							
						</td>
					</tr>
					<tr >
						<td><span> 用户昵称 ：</span></td>
						<td><input type="text" id="input-text" name = "name" class="form-control wid200px"></td>
					</tr>
					<tr > 
						<td><span> 联系电话 ：</span></td>
						<td><input type="text" id="input-text" name = "telephone" class="form-control wid200px"></td>
					</tr>
						<tr >
						<td><span> 邮箱 ：</span></td>
						<td><input type="text" id="input-text" name = "address" class="form-control wid200px"></td>
					</tr>
					<tr >
						<td>
							<span> 性别 ：</span>
						</td>
						<td id="addUser-use">
							<input type="radio" name="sex" value="M" checked="true"></input>
				            <span>男</span>      
				         	<input type="radio" name="sex" value="F"></input>
				            <span>女</span>  
						</td>
					</tr>

					<tr >
						<td><span> 选择角色 ：</span></td>
						<td>
                            <table class="table table-bordered table-center role-table">
                                <thead>
                                <tr>
                                    <td>
                                    	<input id="addUserRoleCheckbox" class="choice-w" type="checkbox" onchange="selectAll('addUserRoleCheckbox','addUserRoleBody')">
                                    </td>
                                    <td>角色名</td>
                                    <td>角色类型</td>
                                </tr>
                                </thead>
                                <tbody id="addUserRoleBody">
                                {{#roleList}}
                                <tr>
                                    <td><input type="checkbox" id="{{id}}" value="{{id}}" name="roleIds"></td>
                                    <td><span>{{name}}</span></td>
                                    <td data-roletype="{{roleType}}"></td>
                                </tr>
                                {{/roleList}}
                                </tbody>
                            </table>
						</td>
					</tr>
				</tbody>

				
			</table>
			<!--  
	    <div id="addRole">
	      {{#roleList}}
	        <input type="checkbox" id="{{id}}" value="{{id}}">
	        <span>{{rolename}}</span>
	      {{/roleList}}
	    </div>
	    -->
		</div>
		<div class="modal-footer">
			<input type="button" value="创建用户" class="btn btn-primary" aria-hidden="true" onclick="addUser()">
			<button class="btn btn-common" data-dismiss="modal" aria-hidden="true">关闭</button>
		</div>
		</form>
		<!-- </div> -->
	<!-- </div> -->
</div>




<!-- 编辑用户界面 -->
<div id="editUserModal" class="modal fade" tabindex="-1" data-backdrop="static"
	role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-height="350" style="display: none;">
	<form  id="editUserForm" style="margin: 0"  name="dataForm" method="post"
		action="editUser">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal"
				aria-hidden="true">×</button>
			<h3 id="myModalLabel">用户信息修改</h3>
		</div>



		<div class="modal-body" style=" overflow: scroll; height: 350px; ">
			<!-- <span> 用户ID </span> -->

			<table class="table table-bordered">
				<tbody >
					
					<tr>

						<td style=" width: 20%;"><span> 用户名: </span></td>
						<td class="edittext">
							<input class="form-control wid200px" id="edituser-userId" name="id" type="hidden"></input>
							<input type="hidden" id="edituser-username" name="username" class="form-control wid200px"></input>
							<span id = "edituser-lb_username"></span>
						</td>
					</tr>
					<tr style="display:none"> 
						<td><span> 密码: </span></td>
						<td class="edittext">

							<input type="password" style ="display:none"></input>
							<input type="password" id="edituser-password" name="password" class="form-control wid200px" onpaste="return false" ></input>
						</td>

					</tr>
					<tr style="display:none">
						<td><span> 密码确认: </span></td>
						<td class="edittext">
						
							<input type="password" style ="display:none"></input>
							<input type="password" id="edituser-password-confirm" name="edit_crmPassword" class="form-control wid200px" onpaste="return false" ></input>
						</td>

					</tr>
					<tr>
						<td><span> 用户昵称: </span></td>
						<td class="edittext">
							<input type="text" id="edituser-name" name="name" class="form-control wid200px"></input>
						</td>

					</tr>
					<tr>
						<td><span> 邮箱: </span></td>
						<td class="edittext">
							<input type="text" id="edituser-address" name="address" class="form-control wid200px"></input>
						</td>

					</tr>
					<tr>
						<td><span> 联系电话: </span></td>
						<td class="edittext">
							<input type="text" id="edituser-telephone" name="telephone" class="form-control wid200px"></input>
						</td>

					</tr>


					<tr>
						<td><span> 性别: </span></td>

						<td id="edituser-sex">
						 
						 	<input type="radio" name="sex" value="M"></input>
				            <span>男</span>      
				         	<input type="radio" name="sex" value="F"></input>
				            <span>女</span>      
						</td>
						
					</tr>

					<tr>
						
						<td>用户角色：</td>
						<td>
							<input type="hidden" id="edituser-status" name="status"></input>
							<div id="edituser-roleList">
                                <table class="table table-bordered table-center role-table">
                                    <thead>
                                        <tr>
                                            <td>
                                            <input id="editUserRoleCheckbox" class="choice-w" type="checkbox" onchange="selectAll('editUserRoleCheckbox','userRoleBody')">
                                            </td>
                                            <td>角色名</td>
                                            <td>角色类型</td>
                                        </tr>
                                    </thead>
                                    <tbody id="userRoleBody">
								    {{#roleList}}
                                        <tr>
                                            <td><input type="checkbox" id="{{id}}" value="{{id}}" name="roleIds"></td>
                                            <td><span>{{name}}</span></td>
                                            <td data-roletype="{{roleType}}"></td>
                                        </tr>
								    {{/roleList}}
                                    </tbody>
                                </table>
                            </div>

						</td>
			
					</tr>
				</tbody>
			</table>



			
		</div>

		<div class="modal-footer">
			<input type="button" value="更新用户信息" id="btn-submitUserInfo" class="btn btn-primary" aria-hidden="true" />
			<button class="btn btn-common" data-dismiss="modal" aria-hidden="true">关闭</button>
		</div>

	</form>

</div>

<!-- 编辑用户界面 -->
<div id="setPasswordModal" class="modal fade" tabindex="-1" data-backdrop="static"
	role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-height="200" style="display: none;">
	<form  id="setPasswordForm" style="margin: 0" name="dataForm" method="post"
		action="editUser">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal"
				aria-hidden="true">×</button>
			<h3 id="myModalLabel">密码修改</h3>
		</div>



		<div class="modal-body" style=" overflow: scroll; height: 200px; ">
			<!-- <span> 用户ID </span> -->

			<table class="table table-bordered">
				<tbody >
					
					<tr>

						<td style=" width: 20%;"><span> 用户名: </span></td>
						<td class="edittext">
							<input class="form-control wid200px" id="editpsw-userId" name="id" type="hidden"></input>
							<input type="hidden" id="editpsw-username" name="username" class="form-control wid200px"></input>
							<span id = "editpsw-lb_username"></span>
						</td>
					</tr>
					<tr>
						<td><span> 密码: </span></td>
						<td class="edittext">
						<!-- 欺骗浏览器记住密码的功能 -->
							<input type="password" style ="display:none"></input>
							<input type="password" id="editpsw-password" name="password" class="form-control wid200px" onpaste="return false" ></input>
						</td>

					</tr>
					<tr>
						<td><span> 密码确认: </span></td>
						<td class="edittext">
							<input type="password" id="editpsw-password-confirm" name="edit_crmPassword" class="form-control wid200px" onpaste="return false" ></input>
						</td>

					</tr>
					
				</tbody>
			</table>



			
		</div>

		<div class="modal-footer">
			<input type="button" value="提交" id="btn-submitPassword" class="btn btn-primary" aria-hidden="true" />
			<button class="btn btn-common" data-dismiss="modal" aria-hidden="true">关闭</button>
		</div>

	</form>

</div>

<div id="importUserModal" class="modal fade" tabindex="-1" data-backdrop="static"
	role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
	<input class="In" type="hidden" id="versionIdhidden" />
	<div class="modal-header">
		<button type="button" class="close" data-dismiss="modal"
			aria-hidden="true">×</button>
		<h3 id="myModalLabel">Excel批量导入用户</h3>
	</div>
	<div class="modal-body">
		<div class="text-right pad-st-b5">
			<form  id="upload" style="margin: 0" name="upload" method="post" enctype="multipart/form-data"
				action="importUser">
				<fieldset id="form-set">
					<div class="control-group">
						<!-- <label class="control-label" for="focusedInput">excel文件:</label> -->
						<div class="controls">
							<input type="file" id="file" name="file" />
						</div>
					</div>
				</fieldset>
				</form>
		</div>
	</div>

	<div class="modal-footer">
		<button class="btn btn-primary btn-sm tls" onclick="uploadUser()">保存</button>
		<button class="btn btn-common btn-sm tls" data-dismiss="modal"
			aria-hidden="true">关闭</button>
	</div>	
</div>

